#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "dragpushbutton.h"
#include "macro.h"
#include "type.h"
#include <QMainWindow>
#include <QMessageBox>
#include <QParallelAnimationGroup>
#include <QPropertyAnimation>
#include <QSequentialAnimationGroup>
#include <QThread>
#include <QTime>
#include <QtGlobal>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow {
    Q_OBJECT

public:
    explicit MainWindow(QWidget* parent = nullptr);
    ~MainWindow();

public slots:
    void swapBlock(int i0, int j0, int i1, int j1);

private slots:
    void on_actionReset_triggered();

    void on_actionQuit_triggered();

    void on_actionNewGame_triggered();

    void on_actionAbout_triggered();

    void on_actionRecord_triggered();

    void on_pushButton_clicked();

private:
    void btn_init();

    void block_init();

    void flush(bool animate);

    void drop(bool animate = true);

    void set_score(int s = 0);

    int cal_score();

    void match_scan();

    Ui::MainWindow* ui;

    int mat[COL_SIZE][ROW_SIZE];

    bool eliminated[COL_SIZE][ROW_SIZE];

    DragPushButton* btns[COL_SIZE][ROW_SIZE];

    int score = 0;
};

#endif // MAINWINDOW_H
